<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

    <link rel="stylesheet" href="../js/bootstrap/css/bootstrap.min.css">
    <title>会员登录</title>
</head>
<body>

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <ul class="bg-danger" id="errorDiv"></ul>
            <form class="form-horizontal" >
                <div class="form-group">
                    <label  class="col-sm-2 control-label">会员名:</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" id="memberName"  placeholder="请输入会员名" >
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-sm-2 control-label">密码:</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control" id="password"  placeholder="请输入密码">
                    </div>
                </div>
                <div style="text-align: center;">
                    <button type="button" class="btn btn-primary"  onclick="login();">登录</button>
                    <button type="reset" class="btn btn-default">重置</button>
                    <button type="button" class="btn btn-default" onclick="toMail();">发送邮件，再次激活</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="../js/jquery-3.3.1.js"></script>
<script src="../js/bootstrap/js/bootstrap.min.js"></script>
<script src="../js/common/common.js"></script>
<script>

    function login() {
        let v_param = {};
        v_param.memberName = $("#memberName").val();
        v_param.password = $("#password").val();

        // js验证

        // 访问后台请求
        $.ajax({
            type:"post",
            url:config.SERVER_URL+"members/login",
            data:v_param,
            success(res) {
                if (res.code == config.SUCCESS) {
                    console.log(res);
                    // x.y [token]
                    let v_data = res.data;
                    // 存值
                    sessionStorage.setItem(config.X_TOKEN, v_data);
                    // 跳转到首页
                    location.href = "index.html";
                } else {
                    alert(res.msg);
                }
            }
        })
    }

    function toMail() {
        location.href = "mail.html"
    }

</script>
</body>
</html>